package org.flower.web.servlet;

import org.flower.service.OrderService;
import org.flower.service.impl.OrderServiceImpl;

import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.annotation.*;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(value = "/UpdateStateOrderServlet.shtml")
public class UpdateStateOrderServlet extends HttpServlet {
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String id = request.getParameter("id");
        PrintWriter writer= response.getWriter();
        OrderService orderService = new OrderServiceImpl();
        if (orderService.updateDingdan(id)){
            writer.write(
                    "<script type=\"text/javascript\">alert('收货成功！');setInterval(\"\",10);parent.location.href='" +
                            request.getContextPath()
                            + "/user/orderServlet.shtml'</script>");
            writer.flush();
            writer.close();
        }else {
            response.sendRedirect("order.jsp");
        }
    }

    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    }
}
